/**
 * @title GetCodeCommunicater.java
 * @package com.esun.cheetah.biz.personal.bindcellphone
 * @description 
 * @author liugan
 * @date 2012-4-24
 * @copyright 深圳市易讯天空
 */
package com.esun.cheetah.biz.personal.bindcellphone;

import java.util.HashMap;

import org.json.JSONException;

import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;

import com.esun.cheetah.config.BizCode;
import com.esun.cheetah.config.Config;
import com.esun.cheetah.config.Key;
import com.esun.cheetah.network.AbsInferiorityCommunicater;

/**
 * @title GetCodeCommunicater
 * @description 绑定手机时获取短信验证码
 * @author liugan
 */
public class GetCodeCommunicater extends AbsInferiorityCommunicater {

	private String mOldNumber;
	private String mNumber;
	private String mCk;

	/**
	 * @param handler
	 */
	public GetCodeCommunicater(Handler handler, String oldNumber,
			String number, String ck) {
		super(handler);
		this.mOldNumber = oldNumber;
		this.mNumber = number;
		this.mCk = ck;
	}

	@Override
	public HashMap<String, String> comHashMap() {
		HashMap<String, String> hmJson = new HashMap<String, String>();
		hmJson.put(Key.KEY_ID, BizCode.GET_CODE_FOR_BIND_MOBILE);
		if (!TextUtils.isEmpty(this.mOldNumber)) {
			hmJson.put(Key.KEY_OLD_NUMBER, this.mOldNumber);
		}
		hmJson.put(Key.KEY_PHONE_NUMBER, this.mNumber);
		hmJson.put(Key.KEY_CK, this.mCk);
		return hmJson;
	}

	@Override
	public void getJsonContent(String serverRes) throws JSONException {

	}

	@Override
	public void getServerResponseFail(String serverRes) {
		Message msg = handlerFromAct.obtainMessage(Config.COMMUNICATER_FAIL);
		msg.obj = this.getServerMsg();
		handlerFromAct.sendMessage(msg);
	}

	@Override
	public void getServerResponseSuccess() {
		Message msg = handlerFromAct.obtainMessage(Config.COMMUNICATER_SUCCESS);
		msg.obj = this.mNumber;
		handlerFromAct.sendMessage(msg);
	}

}
